function doSearch() {
	$('#tt').datagrid('load', {
		useful : $('#isUseful').combobox('getValue'),
	});
	$('#tt').datagrid('unselectAll');
}

function add() {
	showMyWindow('微信任务配置 |新增', '/weixinTaskConfig/addConfig', 500, 300);
}

function edit() {
	var row = $('#tt').datagrid('getSelected');
	if (row) {
		showMyWindow('微信任务配置 | 编辑', '/weixinTaskConfig/' + row.id + '/configUpdate', 500, 300);
	} else {
		showMsg(market.content.title, market.content.tips, alert);
	}
}

function abandon() {
	var row = $('#tt').datagrid('getSelected');
	var isUseful = row.useful;
	if (isUseful == 0) {
		top.showMsg(market.content.title, "数据已经是废弃状态", alert);
		return;
	} else {
		$.messager.confirm('温馨提醒', '你确定废弃本条数据吗？', function(r) {
			if (r) {
				$.get('/weixinTaskConfig/abandon?id=' + row.id,
						function(data) {
							if (data.return_code == '1') {
								top.showMsg(market.content.title,
										data.return_msg, alert);
								doSearch();
							} else if (data.return_code == '3') {
								top.showMsg(market.content.title,
										data.return_msg, alert);
							} else {
								$.messager.alert(market.content.title,
										data.return_msg);
							}
						});
			}
		});
	}
}

function effect() {
	var row = $('#tt').datagrid('getSelected');
	var isUseful = row.useful;
	if (isUseful == 1) {
		top.showMsg(market.content.title, "数据已经是启用状态", alert);
		return;
	} else {
		$.messager.confirm('温馨提醒', '你确定启用本条数据吗？', function(r) {
			if (r) {
				$.get('/weixinTaskConfig/effect?id=' + row.id,
						function(data) {
							if (data.return_code == '1') {
								top.showMsg(market.content.title,
										data.return_msg, alert);
								doSearch();
							} else if (data.return_code == '3') {
								top.showMsg(market.content.title,
										data.return_msg, alert);
							} else {
								$.messager.alert(market.content.title,
										data.return_msg);
							}
						});
			}
		});
	}
}

function formatterTaskType(value) {
	if (value == 1) {
		return "关注";
	}
	if (value == 2) {
		return "投票";
	}

	if (value == 3) {
		return "阅读";
	}

}

function formatterType(value) {
	if (value == 1) {
		return "启用";
	}
	if (value == 0) {
		return "作废";
	}

}

function submitDataForm(url, obj) {
	var isUseful = $('#isUseful').combobox('getValue');

	$('#ff')
			.form(
					'submit',
					{
						url : url,
						onSubmit : function() {
							$("#isUseful").val(isUseful);
						},
						success : function(data) {
							showProcess(false);
							var data = eval('(' + data + ')');
							if (data.return_code == '1') {
								top.showMsg(market.content.title,
										data.return_msg, alert);
							} else {
								$.messager.alert(market.content.title,
										data.return_msg);
							}
						},
						onLoadError : function() {
							showProcess(false);
							$.messager.alert(market.content.title,
									market.content.networkError);
						}
					});

}